<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">
        <!-- 示例-970 -->
        <ins class="adsbygoogle" style="display:inline-block;width:970px;height:90px"
             data-ad-client="ca-pub-6111334333458862" data-ad-slot="3820120620"></ins>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
            <legend>用户信息修改</legend>
        </fieldset>
        <form class="layui-form" action="" lay-filter="example">
            <div class="layui-form-item" hidden>
                <label class="layui-form-label">ID</label>
                <div class="layui-input-block">
                    <input type="text" name="id" lay-verify="title" autocomplete="off" placeholder="请输入标题"
                           class="layui-input" disabled>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input type="text" name="username" lay-verify="title" autocomplete="off" placeholder="输入新用户名"
                           class="layui-input" disabled>
                </div>
            </div>
            <!--            Lu 4.12 up-->
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="text" name="password" lay-verify="title" autocomplete="off" placeholder="输入新密码"
                           class="layui-input">
                </div>
            </div>
            <!--            Lu 4.12 up END-->
            <div class="layui-form-item">
                <label class="layui-form-label">余额</label>
                <div class="layui-input-block">
                    <input type="text" name="balance" placeholder="请输入余额" autocomplete="off"
                           class="layui-input"  disabled>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    layui.use(['form', 'layedit', 'jquery'], function () {
        var form = layui.form
            , layer = layui.layer
            , $ = layui.jquery;

        //监听提交
        form.on('submit(demo1)', function (data) {
            data = data.field
            console.log(data);
            // $.post("http://localhost:8080/user/upd", {
            $.post("http://localhost:8080/changeinfo", {
                id: data.id,
                username: data.username,
                balance: data.balance,
                //Lu 4.12 up
                password: data.password,
                //Lu 4.12 up END
            }, resu => {
                layer.open({
                    type:1,
                    content:"修改成功，请重新登录",
                    area: ['200px', '100px']
                })
                // 函数回调
                console.log(resu)
            })
            return false;
        });

        //表单初始赋值
        form.val('example', {
            "username": sessionStorage.getItem("userInfo") // "name": "value"
            , "balance": "500000"
        })
    });
</script>
